package com.demo.web;

import com.demo.model.User;
import com.demo.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HelloController {
    @Autowired
    private HelloService helloService;

    @RequestMapping(value = "/hello")
    public String hello(Model model) {
        model.addAttribute("hello", helloService.hello());
        return "hello";
    }

    @RequestMapping(value = "/user")
    public String getUser(Model model) {
        User user = helloService.getUser(2);
        model.addAttribute("user", user);
        return "user";
    }
}
